<template>
  <div class="goods">
    <div
      class="goods-item"
      v-for="item in goods"
      :key="item.acm"
      @click="goDetail(item)"
    >
      <img
        v-lazy="item.img || item.image || item.show.img"
        alt=""
        @load="imageLoad"
      />
      <div class="goods-info">
        <p>{{ item.title }}</p>
        <span class="price">{{ item.price }}</span>
        <span class="collect">{{ item.cfav }}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "GoodsList",
  components: {},
  methods: {
    imageLoad() {
      this.$bus.$emit("itemImageLoad");
    },
    goDetail(item) {
      console.log(item);
      this.$router.push("/detail/" + item.iid);
    },
  },
  props: {
    goods: {
      type: Array,
      default() {
        return [];
      },
    },
  },
};
</script>

<style lang="less" scoped>
.goods {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;

  padding: 2px;
}
.goods-item {
  margin-bottom: 20px;
  /* position: relative; */
  display: flex;
  flex-direction: column;
  width: 48%;
  justify-content: space-between;
}

.goods-item img {
  width: 100%;
  border-radius: 5px;
}

.goods-info {
  margin-top: 10px;
  font-size: 12px;
  /* position: absolute;
  bottom: 5px;
  left: 0;
  right: 0; */

  text-align: center;
  p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 3px;
  }
  .price {
    color: var(--color-high-text);
    margin-right: 20px;
  }
  .collect {
    position: relative;
    &::before {
      content: "";
      position: absolute;
      left: -15px;
      top: -1px;
      width: 14px;
      height: 14px;
      background: url("~assets/img/common/collect.svg") 0 0/14px 14px;
    }
  }
}
</style>
